//
//  User1.m
//  TuiTe
//
//  Created by 张 霄鹤 on 10-4-1.
//  Copyright 2010 xhzhang. All rights reserved.
//

#import "User1.h"


@implementation User1

@synthesize uid;
@synthesize name;
@synthesize screen_name;
@synthesize location;
@synthesize udescription;
@synthesize profile_image_url;
@synthesize url;
@synthesize isProtected;
@synthesize followers_count;
@synthesize profile_background_color;
@synthesize profile_text_color;
@synthesize profile_link_color;
@synthesize profile_sidebar_fill_color;
@synthesize profile_sidebar_border_color;
@synthesize friends_count;
@synthesize created_at;
@synthesize favourites_count;
@synthesize profile_background_image_url;
@synthesize geo_enabled;
@synthesize verified;
@synthesize following;
@synthesize statuses_count;
@synthesize status;

- (void)parse:(Element *)el{
	Node *nd = [el getChildByName:@"id"];
	if(nd){
		self.uid = [[nd getChildByName:@"#TEXT"] getValue];
	}
	
	nd = [el getChildByName:@"name"];
	if(nd){
		// self.name = [[nd getChildByName:@"#TEXT"] getValue];
		Element *exx = (Element *)nd;
		NSArray *es = [exx getElementsByName:@"#TEXT"];
		if(es){
			NSMutableString *str = [[NSMutableString alloc] init];
			for(Node *dn in es){
				[str appendString:[dn getValue]];
			}
			self.name = str;
			[str release];
		}
	}
	
	nd = [el getChildByName:@"screen_name"];
	if(nd){
		// self.screen_name = [[nd getChildByName:@"#TEXT"] getValue];
		Element *exx = (Element *)nd;
		NSArray *es = [exx getElementsByName:@"#TEXT"];
		if(es){
			NSMutableString *str = [[NSMutableString alloc] init];
			for(Node *dn in es){
				[str appendString:[dn getValue]];
			}
			self.screen_name = str;
			[str release];
		}
	}
	
	nd = [el getChildByName:@"location"];
	if(nd){
		self.location = [[nd getChildByName:@"#TEXT"] getValue];
	}
	
	nd = [el getChildByName:@"description"];
	if(nd){
		// self.udescription = [[nd getChildByName:@"#TEXT"] getValue];
		Element *exx = (Element *)nd;
		NSArray *es = [exx getElementsByName:@"#TEXT"];
		if(es){
			NSMutableString *str = [[NSMutableString alloc] init];
			for(Node *dn in es){
				[str appendString:[dn getValue]];
			}
			self.udescription = str;
			[str release];
		}
	}
	
	nd = [el getChildByName:@"profile_image_url"];
	if(nd){
		self.profile_image_url = [[nd getChildByName:@"#TEXT"] getValue];
	}
	
	nd = [el getChildByName:@"url"];
	if(nd){
		self.url = [[nd getChildByName:@"#TEXT"] getValue];
	}
	
	nd = [el getChildByName:@"protected"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.isProtected = [ns isEqualToString:@"true"];
	}
	
	nd = [el getChildByName:@"followers_count"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.followers_count = [ns intValue];
	}
	
	nd = [el getChildByName:@"profile_background_color"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.profile_background_color = [ns intValue];
	}
	nd = [el getChildByName:@"profile_text_color"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.profile_text_color = [ns intValue];
	}
	nd = [el getChildByName:@"profile_link_color"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.profile_link_color = [ns intValue];
	}
	nd = [el getChildByName:@"profile_sidebar_fill_color"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.profile_sidebar_fill_color = [ns intValue];
	}
	nd = [el getChildByName:@"profile_sidebar_border_color"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.profile_sidebar_border_color = [ns intValue];
	}
	nd = [el getChildByName:@"friends_count"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.friends_count = [ns intValue];
	}
	
	nd = [el getChildByName:@"created_at"];
	if(nd){
		self.created_at = [[nd getChildByName:@"#TEXT"] getValue];
	}
	
	nd = [el getChildByName:@"favourites_count"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.favourites_count = [ns intValue];
	}
	
	nd = [el getChildByName:@"profile_background_image_url"];
	if(nd){
		self.profile_background_image_url = [[nd getChildByName:@"#TEXT"] getValue];
	}
	
	nd = [el getChildByName:@"geo_enabled"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.geo_enabled = [ns isEqualToString:@"true"];
	}
	
	nd = [el getChildByName:@"verified"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.verified = [ns isEqualToString:@"true"];
	}
	nd = [el getChildByName:@"following"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.following = [ns isEqualToString:@"true"];
	}
	nd = [el getChildByName:@"statuses_count"];
	if(nd){
		NSString *ns = [[nd getChildByName:@"#TEXT"] getValue];
		self.statuses_count = [ns intValue];
	}
	
	nd = [el getChildByName:@"status"];
	if(nd){
		self.status = nil;
		Status *st = [[Status alloc] init];
		[st parse:(Element *)nd];
		self.status = st;
		[st release];
	}
	
}


@end
